#include "constants.h"

// init include server
if (isServer) then {
	if (d_global_debug > 0) then { diag_log Format["(%1)[%2]: %3",diag_tickTime,"i_server.sqf","Starting Execution"]; };
	// turn on/off smoke, means enemy will throw smoke grenades if true
	d_smoke = true;

	// _E = East
	// _W = West
	// _G = Guer
	// this is what gets spawned
	if (isnil "d_allmen_E") then {
		d_allmen_E = [
			["East","RU","Infantry","RU_InfSquad"] call XfGetConfigGroup,
			["East","RU","Infantry","RU_InfSection"] call XfGetConfigGroup,
			["East","RU","Infantry","RU_InfSection_AT"] call XfGetConfigGroup,
			["East","RU","Infantry","RU_InfSection_AA"] call XfGetConfigGroup,
			["East","RU","Infantry","RU_InfSection_MG"] call XfGetConfigGroup,
			["East","RU","Infantry","RU_SniperTeam"] call XfGetConfigGroup,
			["East","RU","Infantry","RUS_ReconTeam"] call XfGetConfigGroup,
			["East","RU","Infantry","MVD_AssaultTeam"] call XfGetConfigGroup,
			["East","INS","Infantry","INS_InfSquad"] call XfGetConfigGroup,
			["East","INS","Infantry","INS_InfSquad_Weapons"] call XfGetConfigGroup,
			["East","INS","Infantry","INS_InfSection_AT"] call XfGetConfigGroup,
			["East","INS","Infantry","INS_InfSection_AA"] call XfGetConfigGroup,
			["East","INS","Infantry","INS_SniperTeam"] call XfGetConfigGroup,
			["East","INS","Infantry","INS_MilitiaSquad"] call XfGetConfigGroup
		];
	};
	if (isnil "d_allmen_W") then {
		d_allmen_W = [
			["West","USMC","Infantry","USMC_InfSquad"] call XfGetConfigGroup,
			["West","USMC","Infantry","USMC_FireTeam"] call XfGetConfigGroup,
			["West","USMC","Infantry","USMC_FireTeam_MG"] call XfGetConfigGroup,
			["West","USMC","Infantry","USMC_FireTeam_AT"] call XfGetConfigGroup,
			["West","USMC","Infantry","USMC_FireTeam_Support"] call XfGetConfigGroup,
			["West","USMC","Infantry","USMC_HeavyATTeam"] call XfGetConfigGroup,
			["West","USMC","Infantry","USMC_SniperTeam"] call XfGetConfigGroup,
			["West","USMC","Infantry","USMC_FRTeam"] call XfGetConfigGroup,
			["West","USMC","Infantry","USMC_FRTeam_Razor"] call XfGetConfigGroup,
			["West","CDF","Infantry","CDF_InfSquad"] call XfGetConfigGroup,
			["West","CDF","Infantry","CDF_InfSquad_Weapons"] call XfGetConfigGroup,
			["West","CDF","Infantry","CDF_InfSection_AT"] call XfGetConfigGroup,
			["West","CDF","Infantry","CDF_InfSection_AA"] call XfGetConfigGroup,
			["West","CDF","Infantry","CDF_InfSection_MG"] call XfGetConfigGroup,
			["West","CDF","Infantry","CDF_InfSection_Patrol"] call XfGetConfigGroup,
			["West","CDF","Infantry","CDF_SniperTeam"] call XfGetConfigGroup
		];
	};
	if (isnil "d_allmen_G") then {
		d_allmen_G = [
			["Guerrila","GUE","Infantry","GUE_InfSquad"] call XfGetConfigGroup,
			["Guerrila","GUE","Infantry","GUE_InfSquad_Assault"] call XfGetConfigGroup,
			["Guerrila","GUE","Infantry","GUE_InfSquad_Weapons"] call XfGetConfigGroup,
			["Guerrila","GUE","Infantry","GUE_InfTeam_1"] call XfGetConfigGroup,
			["Guerrila","GUE","Infantry","GUE_InfTeam_2"] call XfGetConfigGroup,
			["Guerrila","GUE","Infantry","GUE_InfTeam_AT"] call XfGetConfigGroup,
			["Guerrila","GUE","Infantry","GUE_GrpInf_TeamAA"] call XfGetConfigGroup,
			["Guerrila","GUE","Infantry","GUE_GrpInf_TeamSniper"] call XfGetConfigGroup,
			["Guerrila","GUE","Infantry","GUE_MilitiaSquad"] call XfGetConfigGroup
		];
	};

	if (isnil "d_specops_E") then {
		d_specops_E = ["RUS_Soldier_TL","RUS_Soldier_GL","RUS_Soldier_Marksman","RUS_Soldier3","RUS_Soldier1","RUS_Soldier2"];
	};
	if (isnil "d_specops_W") then {
		d_specops_W = ["FR_TL","FR_AC","FR_GL","FR_Commander","FR_AR","FR_R","FR_Corpsman","FR_Marksman","FR_Sapper","FR_Assault_R","FR_Assault_GL"];
	};
	if (isnil "d_specops_G") then {
		d_specops_G = ["GUE_Soldier_Sab","GUE_Soldier_Scout","GUE_Soldier_Scout","GUE_Soldier_Scout"];
	};

	if (isnil "d_snipers_E") then {
		d_snipers_E = ["RU_Soldier_Marksman","RU_Soldier_AR","RUS_Soldier_Marksman","MVD_Soldier_Marksman","MVD_Soldier_Sniper","RUS_Soldier2"];
	};
	if (isnil "d_snipers_W") then {
		d_snipers_W = ["FR_Marksman","FR_R","USMC_SoldierM_Marksman","USMC_SoldierS_Sniper","USMC_SoldierS_Spotter","USMC_SoldierS_SniperH","USMC_Soldier_AR"];
	};
	if (isnil "d_snipers_G") then {
		d_snipers_G = ["GUE_Soldier_Sniper","GUE_Soldier_AR","GUE_Soldier_Scout","GUE_Woodlander2"];
	};

	if (isnil "d_veh_a_E") then {
		d_veh_a_E = [
			["T90","T72_RU"],
			["BMP3","BRDM2_INS","BMP2_INS","BTR90"],
			["BTR90","BRDM2_INS","BRDM2_ATGM_INS"],
			["Ural_ZU23_INS","2S6M_Tunguska","Ural_ZU23_INS","ZSU_INS","Ural_ZU23_INS"],
			["GAZ_Vodnik","GAZ_Vodnik_HMG","Ural_ZU23_INS"],
			["UAZ_MG_INS","UAZ_AGS30_RU","UAZ_MG_INS","UAZ_AGS30_INS","UAZ_MG_INS","UAZ_SPG9_INS","UAZ_MG_INS"],
			["KORD","AGS_RU","DSHKM_Ins","AGS_RU","KORD_high","Metis","DSHkM_Mini_TriPod","SPG9_Ins"],
			["ZU23_Ins","Igla_AA_pod_East","ZU23_CDF"],
			["D30_RU","GRAD_RU"],
			["KamazRefuel"],
			["KamazRepair"],
			["KamazReammo"],
			["Kamaz"]
		];
	};

	if (isnil "d_veh_a_W") then {
		d_veh_a_W = [
			["M1A1","M1A2_TUSK_MG","T72_CDF"],
			["LAV25","BRDM2_CDF","BRDM2_ATGM_CDF"],
			["AAV","BMP2_CDF"],
			["HMMWV_Avenger","ZSU_CDF"],
			["HMMWV_M2","HMMWV_MK19","HMMWV_TOW","UAZ_AGS30_CDF"],
			["HMMWV_M2","HMMWV_Armored","HMMWV_TOW","HMMWV_M2","UAZ_AGS30_CDF","HMMWV_M2","UAZ_MG_CDF"],
			["M2StaticMG","MK19_TriPod","M2HD_mini_TriPod","MK19_TriPod","M2StaticMG","TOW_TriPod","M2StaticMG"],
			["Stinger_Pod"],
			["M119","GRAD_CDF"],
			["MtvrRefuel"],
			["MtvrRepair"],
			["MtvrReammo"],
			["MTVR"]
		];
	};
	if (isnil "d_veh_a_G") then {
		d_veh_a_G = [
			["T34","T72_Gue","T34"],
			["BMP2_Gue"],
			["BRDM2_Gue"],
			["Ural_ZU23_Gue"],
			["Offroad_DSHKM_Gue","Offroad_SPG9_Gue"],
			["Offroad_DSHKM_Gue","Offroad_SPG9_Gue","Offroad_DSHKM_Gue"],
			["DSHKM_Gue","SPG9_Gue","DSHKM_Gue","SPG9_Gue","DSHKM_Gue"],
			["ZU23_Gue"],
			["ZU23_Gue"],
			["V3S_Gue"],
			["V3S_Gue"],
			["V3S_Gue"],
			["V3S_Gue"]
		];
	};

	if (isnil "d_civilian_E") then {
		d_civilian_E = ["RU_Villager1","RU_SchoolTeacher","RU_Villager3","RU_Woodlander2","RU_Worker1","RU_Worker3","RU_Villager2","Citizen1","Profiteer3","Profiteer4","Damsel1","Farmwife1","HouseWife2"];
	};
	if (isnil "d_civilian_W") then {
		d_civilian_W = ["RU_Villager1","RU_SchoolTeacher","RU_Villager3","RU_Woodlander2","RU_Worker1","RU_Worker3","RU_Villager2","Citizen1","Profiteer3","Profiteer4","Damsel1","Farmwife1","HouseWife2"];
	};
	if (isnil "d_civilian_G") then {
		d_civilian_G = ["RU_Villager1","RU_SchoolTeacher","RU_Villager3","RU_Woodlander2","RU_Worker1","RU_Worker3","RU_Villager2","Citizen1","Profiteer3","Profiteer4","Damsel1","Farmwife1","HouseWife2"];
	};
	
	if (isnil "d_special_mission_characters_E") then {
		d_special_mission_characters_E = [];
		d_special_mission_characters_E set [XF_MISSION_CHAR_CIVILIAN_WOMEN	, ["Damsel1","Damsel2","Damsel4","Hooker1","Hooker2","Hooker3","Hooker4","Hooker5"]];  
		d_special_mission_characters_E set [XF_MISSION_CHAR_CIVILIAN_MEN	, ["Functionary1""Functionary2","Citizen4","Citizen3"]];  
		d_special_mission_characters_E set [XF_MISSION_CHAR_CIVILIAN_OFFICIAL, ["Functionary1","Functionary2"]];  
		d_special_mission_characters_E set [XF_MISSION_CHAR_CIVILIAN_CRIMINAL, ["Profiteer1","Profiteer2","Profiteer3"]];  
		d_special_mission_characters_E set [XF_MISSION_CHAR_MILITARY_OFFICER, ["RUS_Commander","RU_Commander"]];  
		d_special_mission_characters_E set [XF_MISSION_CHAR_MILITARY_PILOT, ["RU_Soldier_Pilot"]];  
		d_special_mission_characters_E set [XF_MISSION_CHAR_MILITARY_CREW, ["RU_Soldier_Crew"]];  
		d_special_mission_characters_E set [XF_MISSION_CHAR_MILITARY_SOLDIER, ["RU_Soldier_Light"]];  
		d_special_mission_characters_E set [XF_MISSION_CHAR_SPY, ["Ins_Lopotev"]];  
		d_special_mission_characters_E set [XF_MISSION_CHAR_INFORMER, ["Rocker1","Rocker2","Rocker3"]];  
	};
	
	if (isnil "d_special_mission_characters_W") then {
		d_special_mission_characters_W = [];
		d_special_mission_characters_W set [XF_MISSION_CHAR_CIVILIAN_WOMEN	, ["Damsel1","Damsel2","Damsel4","Hooker1","Hooker2","Hooker3","Hooker4","Hooker5"]];  
		d_special_mission_characters_W set [XF_MISSION_CHAR_CIVILIAN_MEN	, ["Functionary1""Functionary2","Citizen4","Citizen3"]];  
		d_special_mission_characters_W set [XF_MISSION_CHAR_CIVILIAN_OFFICIAL, ["Functionary1","Functionary2"]];  
		d_special_mission_characters_W set [XF_MISSION_CHAR_CIVILIAN_CRIMINAL, ["Profiteer1","Profiteer2","Profiteer3"]];  
		d_special_mission_characters_W set [XF_MISSION_CHAR_MILITARY_OFFICER, ["RUS_Commander","RU_Commander"]];  
		d_special_mission_characters_W set [XF_MISSION_CHAR_MILITARY_PILOT, ["RU_Soldier_Pilot"]];  
		d_special_mission_characters_W set [XF_MISSION_CHAR_MILITARY_CREW, ["RU_Soldier_Crew"]];  
		d_special_mission_characters_W set [XF_MISSION_CHAR_MILITARY_SOLDIER, ["RU_Soldier_Light"]];  
		d_special_mission_characters_W set [XF_MISSION_CHAR_SPY, ["Ins_Lopotev"]];  
		d_special_mission_characters_W set [XF_MISSION_CHAR_INFORMER, ["Rocker1","Rocker2","Rocker3"]];  
	};
	
	if (isnil "d_special_mission_characters_G") then {
		d_special_mission_characters_G = [];
		d_special_mission_characters_G set [XF_MISSION_CHAR_CIVILIAN_WOMEN	, ["Damsel1","Damsel2","Damsel4","Hooker1","Hooker2","Hooker3","Hooker4","Hooker5"]];  
		d_special_mission_characters_G set [XF_MISSION_CHAR_CIVILIAN_MEN	, ["Functionary1""Functionary2","Citizen4","Citizen3"]];  
		d_special_mission_characters_G set [XF_MISSION_CHAR_CIVILIAN_OFFICIAL, ["Functionary1","Functionary2"]];  
		d_special_mission_characters_G set [XF_MISSION_CHAR_CIVILIAN_CRIMINAL, ["Profiteer1","Profiteer2","Profiteer3"]];  
		d_special_mission_characters_G set [XF_MISSION_CHAR_MILITARY_OFFICER, ["RUS_Commander","RU_Commander"]];  
		d_special_mission_characters_G set [XF_MISSION_CHAR_MILITARY_PILOT, ["RU_Soldier_Pilot"]];  
		d_special_mission_characters_G set [XF_MISSION_CHAR_MILITARY_CREW, ["RU_Soldier_Crew"]];  
		d_special_mission_characters_G set [XF_MISSION_CHAR_MILITARY_SOLDIER, ["RU_Soldier_Light"]];  
		d_special_mission_characters_G set [XF_MISSION_CHAR_SPY, ["Ins_Lopotev"]];  
		d_special_mission_characters_G set [XF_MISSION_CHAR_INFORMER, ["Rocker1","Rocker2","Rocker3"]];  
	};
	
	// When using the automatic populating of towns/villages/objectives, the following tables are used to determine the numbers
	//  of vehicles and enemy troops which will be present.
	// There are 3 modes: 0 max number of armored vehicles, 2 least number of armored vehicles. It's chosen in the setup.sqf.
	// And there are 5 arrays per mode for vehicles and 5 vor footmen. Those are increasing in amount and allow for increasing the amount of enemies on the objective.
	// 1 being the least powerful and 5 the most powerful.
	// This allows for finetuning how defended a particular objective is.
	//
	// Arrays structure:
	// 1) A pair of values indicating the max number of units of this type and the minimum number. The result is a random value between those.
	// 2) A value indicating the type of vehicle to pick it up in the tables d_veh_ here above.
	// 3) An identifier to know what the type of vehicle it represents (for logging purpose only)
	// 4) A multiplier to have X times the amount of units. This allow for bigger group sizes for both vehicles and units (and with only one leader each time for calculations)
	// The number after each group is the "power" of the enemy. By standard, in missions you'll have a power depending on the number of players by increment of 5.
	
	switch (WithLessArmor) do {
		case 0: {
			d_vehicle_numbers_1 = [
				[[0,0], 0,"tank",1], // tanks
				[[0,0], 1,"bmp",1], // apc (bmp)
				[[1,0], 2,"brdm",1], // apc2 (brdm)
				[[0,0], 3,"shilka",1], // aa (shilka)
				[[1,1], 4,"vodnik",1], // wheeled (vodnik)
				[[1,1], 5,"uaz_grenade",1] // jeep (uaz mg or gl)
			];
			d_vehicle_numbers_2 = [
				[[0,0], 0,"tank",1], // tanks
				[[1,0], 1,"bmp",1], // apc (bmp)
				[[1,0], 2,"brdm",1], // apc2 (brdm)
				[[0,0], 3,"shilka",1], // aa (shilka)
				[[1,1], 4,"vodnik",1], // wheeled (vodnik)
				[[2,1], 5,"uaz_grenade",1] // jeep (uaz mg or gl)
			];
			d_vehicle_numbers_3 = [
				[[1,0], 0,"tank",1], // tanks
				[[1,0], 1,"bmp",1], // apc (bmp)
				[[1,0], 2,"brdm",1], // apc2 (brdm)
				[[0,0], 3,"shilka",1], // aa (shilka)
				[[1,1], 4,"vodnik",1], // wheeled (vodnik)
				[[2,2], 5,"uaz_grenade",1] // jeep (uaz mg or gl)
			];
			d_vehicle_numbers_4 = [
				[[1,0], 0,"tank",1], // tanks
				[[1,0], 1,"bmp",1], // apc (bmp)
				[[1,1], 2,"brdm",1], // apc2 (brdm)
				[[1,0], 3,"shilka",1], // aa (shilka)
				[[2,1], 4,"vodnik",1], // wheeled (vodnik)
				[[2,2], 5,"uaz_grenade",1] // jeep (uaz mg or gl)
			];
			d_vehicle_numbers_5 = [
				[[1,1], 0,"tank",1], // tanks
				[[1,1], 1,"bmp",1], // apc (bmp)
				[[1,1], 2,"brdm",1], // apc2 (brdm)
				[[1,0], 3,"shilka",1], // aa (shilka)
				[[1,1], 4,"vodnik",1], // wheeled (vodnik)
				[[4,2], 5,"uaz_grenade",1] // jeep (uaz mg or gl)
			];

			d_statics_1 = [
				[[3,2],6,"Static",1],
				[[0,0],7,"StaticAA",1]
			];
			d_statics_2 = [
				[[3,2],6,"Static",1],
				[[1,0],7,"StaticAA",1]
			];
			d_statics_3 = [
				[[3,2],6,"Static",1],
				[[1,1],7,"StaticAA",1]
			];
			d_statics_4 = [
				[[4,3],6,"Static",1],
				[[2,1],7,"StaticAA",1]
			];
			d_statics_5 = [
				[[5,4],6,"Static",1],
				[[2,1],7,"StaticAA",1]
			];

			d_footunits_1 = [
				[[1,1],0,"basic",1], // basic groups
				[[1,1],1,"specops",1] // specop groups
			];
			d_footunits_2 = [
				[[2,2],0,"basic",1], // basic groups
				[[1,1],1,"specops",1] // specop groups
			];
			d_footunits_3 = [
				[[3,2],0,"basic",1], // basic groups
				[[2,1],1,"specops",1] // specop groups
			];
			d_footunits_4 = [
				[[3,2],0,"basic",1], // basic groups
				[[2,2],1,"specops",1] // specop groups
			];
			d_footunits_5 = [
				[[3,3],0,"basic",1], // basic groups
				[[3,2],1,"specops",1] // specop groups
			];
		};
		case 1: {
			d_vehicle_numbers_1 = [
				[[0,0], 0,"tank",1], // tanks
				[[0,0], 1,"bmp",1], // apc (bmp)
				[[0,0], 2,"brdm",1], // apc2 (brdm)
				[[0,0], 3,"shilka",1], // aa (shilka)
				[[1,1], 4,"vodnik",1], // wheeled (vodnik)
				[[1,1], 5,"uaz_grenade",1] // jeep (uaz mg or gl)
			];
			d_vehicle_numbers_2 = [
				[[0,0], 0,"tank",1], // tanks
				[[0,0], 1,"bmp",1], // apc (bmp)
				[[1,0], 2,"brdm",1], // apc2 (brdm)
				[[0,0], 3,"shilka",1], // aa (shilka)
				[[1,1], 4,"vodnik",1], // wheeled (vodnik)
				[[2,1], 5,"uaz_grenade",1] // jeep (uaz mg or gl)
			];
			d_vehicle_numbers_3 = [
				[[0,0], 0,"tank",1], // tanks
				[[1,0], 1,"bmp",1], // apc (bmp)
				[[1,0], 2,"brdm",1], // apc2 (brdm)
				[[0,0], 3,"shilka",1], // aa (shilka)
				[[1,1], 4,"vodnik",1], // wheeled (vodnik)
				[[2,2], 5,"uaz_grenade",1] // jeep (uaz mg or gl)
			];
			d_vehicle_numbers_4 = [
				[[0,0], 0,"tank",1], // tanks
				[[1,1], 1,"bmp",1], // apc (bmp)
				[[1,0], 2,"brdm",1], // apc2 (brdm)
				[[1,0], 3,"shilka",1], // aa (shilka)
				[[2,1], 4,"vodnik",1], // wheeled (vodnik)
				[[2,2], 5,"uaz_grenade",1] // jeep (uaz mg or gl)
			];
			d_vehicle_numbers_5 = [
				[[0,0], 0,"tank",1], // tanks
				[[1,0], 1,"bmp",1], // apc (bmp)
				[[1,1], 2,"brdm",1], // apc2 (brdm)
				[[1,0], 3,"shilka",1], // aa (shilka)
				[[2,1], 4,"vodnik",1], // wheeled (vodnik)
				[[3,2], 5,"uaz_grenade",1] // jeep (uaz mg or gl)
			];

			d_statics_1 = [
				[[3,2],6,"Static",1],
				[[0,0],7,"StaticAA",1]
			];
			d_statics_2 = [
				[[3,2],6,"Static",1],
				[[1,0],7,"StaticAA",1]
			];
			d_statics_3 = [
				[[3,2],6,"Static",1],
				[[1,1],7,"StaticAA",1]
			];
			d_statics_4 = [
				[[4,3],6,"Static",1],
				[[2,1],7,"StaticAA",1]
			];
			d_statics_5 = [
				[[5,4],6,"Static",1],
				[[2,1],7,"StaticAA",1]
			];

			d_footunits_1 = [
				[[2,1],0,"basic",1], // basic groups
				[[1,1],1,"specops",1] // specop groups
			];
			d_footunits_2 = [
				[[2,2],0,"basic",1], // basic groups
				[[2,1],1,"specops",1] // specop groups
			];
			d_footunits_3 = [
				[[3,2],0,"basic",1], // basic groups
				[[2,2],1,"specops",1] // specop groups
			];
			d_footunits_4 = [
				[[4,3],0,"basic",1], // basic groups
				[[2,2],1,"specops",1] // specop groups
			];
			d_footunits_5 = [
				[[4,4],0,"basic",1], // basic groups
				[[3,2],1,"specops",1] // specop groups
			];
		};
		case 2: {
			d_vehicle_numbers_1 = [
				[[0,0], 0,"tank",1], // tanks
				[[0,0], 1,"bmp",1], // apc (bmp)
				[[0,0], 2,"brdm",1], // apc2 (brdm)
				[[0,0], 3,"shilka",1], // aa (shilka)
				[[1,1], 4,"vodnik",1], // wheeled (vodnik)
				[[2,1], 5,"uaz_grenade",1] // jeep (uaz mg or gl)
			];
			d_vehicle_numbers_2 = [
				[[0,0], 0,"tank",1], // tanks
				[[0,0], 1,"bmp",1], // apc (bmp)
				[[1,0], 2,"brdm",1], // apc2 (brdm)
				[[0,0], 3,"shilka",1], // aa (shilka)
				[[1,1], 4,"vodnik",1], // wheeled (vodnik)
				[[2,2], 5,"uaz_grenade",1] // jeep (uaz mg or gl)
			];
			d_vehicle_numbers_3 = [
				[[0,0], 0,"tank",1], // tanks
				[[0,0], 1,"bmp",1], // apc (bmp)
				[[1,0], 2,"brdm",1], // apc2 (brdm)
				[[0,0], 3,"shilka",1], // aa (shilka)
				[[1,1], 4,"vodnik",1], // wheeled (vodnik)
				[[3,2], 5,"uaz_grenade",1] // jeep (uaz mg or gl)
			];
			d_vehicle_numbers_4 = [
				[[0,0], 0,"tank",1], // tanks
				[[0,0], 1,"bmp",1], // apc (bmp)
				[[1,1], 2,"brdm",1], // apc2 (brdm)
				[[1,0], 3,"shilka",1], // aa (shilka)
				[[1,1], 4,"vodnik",1], // wheeled (vodnik)
				[[3,2], 5,"uaz_grenade",1] // jeep (uaz mg or gl)
			];
			d_vehicle_numbers_5 = [
				[[0,0], 0,"tank",1], // tanks
				[[0,0], 1,"bmp",1], // apc (bmp)
				[[1,1], 2,"brdm",1], // apc2 (brdm)
				[[1,0], 3,"shilka",1], // aa (shilka)
				[[1,1], 4,"vodnik",1], // wheeled (vodnik)
				[[4,4], 5,"uaz_grenade",1] // jeep (uaz mg or gl)
			];

			d_statics_1 = [
				[[3,2],6,"Static",1],
				[[0,0],7,"StaticAA",1]
			];
			d_statics_2 = [
				[[3,2],6,"Static",1],
				[[1,0],7,"StaticAA",1]
			];
			d_statics_3 = [
				[[3,2],6,"Static",1],
				[[1,1],7,"StaticAA",1]
			];
			d_statics_4 = [
				[[4,3],6,"Static",1],
				[[2,1],7,"StaticAA",1]
			];
			d_statics_5 = [
				[[5,4],6,"Static",1],
				[[2,1],7,"StaticAA",1]
			];

			d_footunits_1 = [
				[[2,1],0,"basic",1], // basic groups
				[[2,1],1,"specops",1] // specop groups
			];
			d_footunits_2 = [
				[[2,2],0,"basic",1], // basic groups
				[[2,1],1,"specops",1] // specop groups
			];
			d_footunits_3 = [
				[[3,2],0,"basic",1], // basic groups
				[[2,2],1,"specops",1] // specop groups
			];
			d_footunits_4 = [
				[[5,4],0,"basic",1], // basic groups
				[[3,1],1,"specops",1] // specop groups
			];
			d_footunits_5 = [
				[[6,4],0,"basic",1], // basic groups
				[[3,1],1,"specops",1] // specop groups
			];
		};
	};

	if (isnil "d_airki_attack_plane") then {
		// type of enemy plane that will fly over the main target
		d_airki_attack_plane = switch (d_enemy_side) do {
			case "EAST": {["Su34","Su39"]};
			case "WEST": {["A10","AV8B2","AV8B","F35B"]};
			default {[]};
		};
	};
	
	d_number_attack_planes = 1;

	if (isnil "d_airki_attack_chopper") then {
		// type of enemy chopper that will fly over the main target
		d_airki_attack_chopper = switch (d_enemy_side) do {
			case "EAST": {["Ka52","Ka52Black","Mi24_P","Mi24_V"]};
			case "WEST": {["AH1Z","AH64D","ACE_AH1W_AGM_W","ACE_AH1W_AGM_D"]};
			default {[]};
		};
	};

	d_number_attack_choppers = 1;
	
	// enemy parachute troops transport chopper
	if (isnil "d_transport_chopper") then {
		d_transport_chopper = switch (d_enemy_side) do {
			case "EAST": {["Mi17_rockets_RU"]};
			case "WEST": {["MH60S"]};
			case "GUER": {["Mi17_Civilian"]};
		};
	};

	// light attack chopper (for example Mi17 with MG)
	if (isnil "d_light_attack_chopper") then {
		d_light_attack_chopper = switch (d_enemy_side) do {
			case "EAST": {["Mi17_Ins"]};
			case "WEST": {["UH1Y"]};
			default {[]};
		};
	};
	
	// enemy ai skill: [base skill, random value (random 0.3) that gets added to the base skill]
	d_skill_array = switch (EnemySkill) do {
		case 1: {[0.2,0.2]};
		case 2: {[0.4,0.3]};
		case 3: {[0.5,0.3]};
		case 4: {[0.6,0.3]};
		case 5: {[0.8,0.2]};
	};

	// Default type of aircraft, that will air drop stuff, normally it is defined in the drop array in i_common.sqf
	if (isnil "x_drop_aircraft") then {
		x_drop_aircraft = switch (d_own_side) do {
			case "EAST": {"Mi17_rockets_RU"};
			case "WEST": {"MH60S"};
			case "GUER": {"Mi17_Civilian"};
		};
	};
	
	if (isnil "x_drop_fly_height") then {
		x_drop_fly_height = 120;
	};
	
	if (isnil "x_taxi_aircraft") then {
		x_taxi_aircraft = switch (d_own_side) do {
			case "EAST": {["Mi17_rockets_RU"]};
			case "WEST": {["MH60S"]};
			case "GUER": {["Mi17_Civilian"]};
		};
	};

	if (isnil "d_civilians_t") then { d_civilians_t = []; };
	_civilian = ["Assistant","Citizen1","Citizen2","Citizen2","Citizen4","Worker1","Worker2","Worker3","Worker4","Priest","Doctor","Functionary1","Functionary2","Damsel1","Damsel2","Damsel3","Damsel4","Damsel5","Profiteer1","Profiteer2","Profiteer3","Profiteer4","Rocker1","Rocker2","Rocker3","Rocker4","Woodlander1","Woodlander2","Woodlander3","Woodlander4","Villager1","Villager2","Villager3","Villager4","Secretary1","Secretary2","Secretary3","Secretary4","Sportswoman1","Sportswoman2","Sportswoman3","Sportswoman4","Madam1","Madam2","Madam3","Madam4","Farmwife1","Farmwife2","Farmwife3","Farmwife4","HouseWife1","HouseWife2","HouseWife3","HouseWife4","Hooker1","Hooker2","Hooker3","Hooker4","WorkWoman1","WorkWoman2","WorkWoman3","WorkWoman4","SchoolTeacher","Policeman"];
	if (count _civilian > 0) then {d_civilians_t = [d_civilians_t, _civilian] call XfarrayPushStack};
		
	// position and direction of the AI HUT
	if (isnil "d_pos_ai_hut") then {
		d_pos_ai_hut = [[4671.4,10203.9,0],325];
	};
	// position and direction of the AI Spawn
	if (isnil "d_pos_ai_spawn") then {
		d_pos_ai_spawn = [[4665.1,10208.3,0.01],325];
	};
	// Position and directions of the AI Vehicle Spawn
	if (isnil "d_pos_ai_vehicle_spawn") then {
		d_pos_ai_vehicle_spawn = [[4153.56,10963.9,0],0];
	};

	_wbarracks = switch (d_own_side) do {
		case "WEST": {"USMC_WarfareBBarracks"};
		case "EAST": {"RU_WarfareBBarracks"};
		case "GUER": {"Gue_WarfareBBarracks"};
	};

	If (count d_pos_ai_hut > 0) then {
		_D_AI_HUT = createVehicle [_wbarracks, (d_pos_ai_hut select 0), [], 0, "NONE"];
		_D_AI_HUT setDir (d_pos_ai_hut select 1);
		if (isNil "d_with_carrier") then {
			_D_AI_HUT setPos (d_pos_ai_hut select 0)
		} else {
			_D_AI_HUT setPosASL (d_pos_ai_hut select 0)
		};
		_D_AI_HUT allowDamage false;
		["D_AI_HUT",_D_AI_HUT] call XNetSetJIP;
	};
	
	if (isnil "d_pos_antiairradar") then {
		d_pos_antiairradar = [[4281.9,10535.6,0],200];
	};
	if (WithAntiAirRadar and (count d_pos_antiairradar > 0)) then {
		d_anti_air_radar = createVehicle ["USMC_WarfareBAntiAirRadar", d_pos_antiairradar select 0, [], d_pos_antiairradar select 1, "NONE"];
		d_anti_air_radar setDir (d_pos_antiairradar select 1);
		d_anti_air_radar setPos (d_pos_antiairradar select 0);
	};
	
	if (d_global_debug > 0) then { diag_log Format["(%1)[%2]: %3",diag_tickTime,"i_server.sqf","Ending Execution"];};	

	if (!isnil "d_own_side_flag_texture") then {
		FLAG_BASE setFlagTexture d_own_side_flag_texture;
		_flag_found = true;
		_flag_count = 1;
		while { _flag_found } do {
			_flag_count = _flag_count + 1;
			_flag_name = Format["FLAG_BASE_%1",_flag_count];
			if (!isnil _flag_name) then {
				_flag_object = missionNamespace getVariable _flag_name;
				_flag_object setFlagTexture d_own_side_flag_texture;
			} else {
				_flag_found = false;
			};
		};
	};
};